using System.Collections.Generic;

namespace MimeCloud.Foundations.Extensions
{
    public static class IDictionaryExtensions
    {
        
        public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key)
        {
            return TryGetValue(dict, key, default(TValue));
        }
        
        public static TValue TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey key, TValue defaultValue)
        {
            TValue result;
            if (!dict.TryGetValue(key, out result))
            {
                result = defaultValue;
            }
            return result;
        }
    }
}
